const crypto = require('crypto');

const aesDecrypt = (encrypted, key = 'lanaya') => {
  const decipher = crypto.createDecipher('aes192', key);
  var decrypted = decipher.update(encrypted, 'hex', 'utf8');
  decrypted += decipher.final('utf8');
  return decrypted;
};

const verifyAuth = (auth) => {
  return true;
};

const authorization = function (req, res, next) {
  let url = req.originalUrl;
  if (!/^\/login/.test(url)) {
    let auth = req.headers.authorization;
    verifyAuth(auth) ? next() : next('error');
  } else {
    next();
  }

};

module.exports = authorization;